/**
 * 
 */
package org.gos.mission.service;

import java.sql.Connection;
import java.util.List;

import org.gos.mission.dao.MissionDaoMySQLImpl;
import org.gos.mission.dao.UserDaoMySQLImpl;
import org.gos.mission.domain.User;
import org.gos.mission.util.DB;

/**
 * @author tonyhai
 *
 */
public class UserServiceImpl implements UserService {

	private UserDaoMySQLImpl userDao;

	private static UserServiceImpl usi ;
	
	public UserServiceImpl() {
		userDao = new UserDaoMySQLImpl();
	}
	
	public static UserService getUserService() {
		if(usi == null){
			
			usi = new UserServiceImpl();
			
		}
		return usi;
	}
	
	public List<User> findFriends(User user) {
		Connection conn = null;
		try {
			conn = DB.getConnection(ServiceManager.DB_CONNECTION);
			return userDao.findFriends(conn,user);
		} finally {
			DB.close(conn);
		}
		
	}

}
